<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.pro.bean.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
    function check()
    {
    	if(document.fuser.username.value=="")
    	{
  			alert("用户名不能为空！");
    		document.fuser.username.focus();
   		 	return false;
    	}
    
    	if(document.fuser.password1.value=="")
    	{
    	 	alert("密码不能为空！");
    		document.fuser.password1.focus();
    		return false;
    	}
    
    	if(document.fuser.password2.value!=document.fuser.password1.value)
    	{
    		alert("两次输入的密码不一致！");
    		document.fuser.password2.focus();
    		return false;
    	}
    
     	if(document.fuser.email.value=="")
    	{
     		alert("邮箱不能为空！");
    		document.fuser.email.focus();
    		return false;
    	}
    	else 
    		if(document.fuser.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/i)==-1)
    		{
     			alert("邮箱格式错误!"); 
     			document.fuser.email.focus();
     			return false;
    		}
    }
    </script>
    
	<title>用户添加</title>
	<base href="<%=basePath%>">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/bootstrap.css">
	<script type="text/javascript" src="<%=basePath%>js/bootstrap.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/jquery.js"></script>
	

</head>
 <%
		List list=(List)session.getAttribute("list");
		Iterator it=list.iterator(); 
		System.out.println(list.size());
		%>
<body>
	<div id="bodydiv" style="width:400px;margin:auto;overflow:auto;float:middle" class="table-responsive">
		
		
    		<form action="<%=basePath%>servlet/RegServlet" name="fuser" method="post" onsubmit="return check()">
    			<table width="200px" height="239" border="0" class="table table-bordered table-hover">
    			
      				<tr>
        				<th height="38" class="success" colspan="2" scope="col" align="center">添加用户(带*为必填项)</th>
       	 			</tr>
      				<tr>
      		 			<th width="125" scope="row">用户名：</th>
      		  			<td width="171">
      		  				<input type="text" align="middle" name="username"><font color="#FF0000">*</font>&nbsp;
      		  			</td>
     	 			</tr>
      				<tr>
        				<th scope="row">用户密码：</th>
        				<td>
        					<input type="password" align="middle" name="password1"><font color="#FF0000">*</font>&nbsp;</td>
     		 		</tr>
     		 		<tr>
        				<th scope="row">确认密码：</th>
        				<td>
        					<input type="password" align="middle" name="password2"><font color="#FF0000">*</font>&nbsp;</td>
     		 		</tr>
     				<tr>
        				<th scope="row">邮箱地址：</th>
        				<td>
        					<input type="text" align="middle" name="email"><font color="#FF0000">*</font>&nbsp;
        				</td>
      				</tr>
      				<tr>
        				<th scope="row">所属企业：</th>
        				<td><select name="company">
        				<%
							while(it.hasNext()){
							Unit unit=(Unit)it.next();			
						%>
							<option value="<%=unit.getUnitid() %>"><%=unit.getUnitname() %></option>
						<%} %>
						</select>	</td>
      				</tr>

    			</table>
    		
    			<table>
    						
    				<tr>
    					<td width="70%"></td>
    					<td>
    						<button type="submit" class="btn btn-primary" onclick="submit">提交</button>
							<button type="reset" class="btn btn-primary">重置</button>	
    					</td>
    				</tr>
    			</table>
    		</form>
	

</div>
	
</body>
</html>

